//
//  AppDelegate.m
//  iOSOCProjectDirectory
//
//  Created by BHmac on 2017/6/8.
//  Copyright © 2017年 XieXuan. All rights reserved.
//

#import "AppDelegate.h"
// 自定义子视图标签栏 及 导航栏
#import "WNBaseTabBarController.h"
#import "WNBaseNavigationController.h"
// AppDelegate类别
#import "AppDelegate+IQKeyboardManager.h"

@interface AppDelegate ()

@property(strong, nonatomic)WNBaseTabBarController *tabBarViewController;

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    // 设置主视图
    [self setUpWindow];
    // 设置键盘
    [self IQKeyboardManagerWithapplication:application didFinishLaunchingWithOptions:launchOptions];
    
    return YES;
}

- (void)setUpWindow{
    
    self.tabBarViewController = [[WNBaseTabBarController alloc]init];
    self.window.rootViewController = self.tabBarViewController;
    self.window.backgroundColor = [UIColor whiteColor];
    
}

- (void)applicationWillResignActive:(UIApplication *)application {
    
}

// APP进入后台
- (void)applicationDidEnterBackground:(UIApplication *)application {
    
}

// APP将要从后台返回
- (void)applicationWillEnterForeground:(UIApplication *)application {
    
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    
}


- (void)applicationWillTerminate:(UIApplication *)application {
    
}

/** 获取显示在当前窗口上最顶层的控制器 */
- (UIViewController *)getTopViewController
{
    WNBaseTabBarController *tabC = (WNBaseTabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
    WNBaseNavigationController *navC = (WNBaseNavigationController *)tabC.selectedViewController;
    return navC.topViewController;
}
/** 获取当前控件 所在的 导航控制器 */
- (UINavigationController *)getCurentNavigationController
{
    WNBaseTabBarController *tabC = (WNBaseTabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
    WNBaseNavigationController *navC = (WNBaseNavigationController *)tabC.selectedViewController;
    return navC;
}


@end
